<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>初审设置</title>
    <style>
        .bgc {
            background-color: #01AAED;
        }
    </style>
</head>
<body>
<div class="layui-tab layui-tab-card">
    <ul class="layui-tab-title">
        @foreach ($res['data'] as $key => $val)
            <li @if($key == 0) class="layui-this"  @endif>{{$val['type_name']}}</li>
        @endforeach
    </ul>
    <div class="layui-tab-content">
        @foreach ($res['data'] as $key => $value)
            <div class="layui-tab-item @if($key == 0) layui-show @endif">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>NO</th>
                        <th>风控规则项</th>
                        <th>阈值</th>
                        <th>审核结果</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach ($value['risk_item_list'] as $ckey => $val)
                        <tr>
                            <td>{{$ckey+1}}</td>
                            <td>{{$val['item_desc']}}</td>
                            <td> @if($val['value_two']) <span data-value_one="{{$val['value_one']}}">{{$val['value_one']}}</span>&lt;{{$val['item_title']}}&lt;<span data-value_two="{{$val['value_two']}}">{{$val['value_two']}}</span>
                                @elseif($val['risk_id'] == 67) <span data-value_one=""></span>  @else <span data-value_one="{{$val['value_one']}}">{{$val['value_one']}}</span> @endif
                            </td>
                            <td> @if($val['check_type'] == 1) <span data-check_type="1">拒绝</span> @else <span
                                        data-check_type="3">人工复审</span> @endif </td>
                            <td> @if($val['is_open'] == 0) <span data-is_open="0">关闭</span> @else <span
                                        data-is_open="1">开启</span> @endif </td>


                                <td>
                                    <button type="button"
                                            class="base-btn-{{$val['risk_id']}} layui-btn layui-btn-normal layui-btn-xs">设置
                                    </button>
                                </td>
                            
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        @endforeach
    </div>
</div>

</body>
<script>

</script>
<script>
    $(function () {

        $('.base-btn-3').click(function () {
            let that = this;
            let parent = $(that).parent().parent()[0].children;

            if(parent[2].children[0] == ''){
                var value_one = '';
            }else{
                var value_one = parent[2].children[0].innerText;
            }

            if(typeof parent[2].children[1] == 'undefined'){
                var value_two = '';
            }else{
                var value_two = parent[2].children[1].innerText;
            }

            let check_type = parent[3].children[0].attributes[0].value;
            let isopen = parent[4].children[0].attributes[0].value;

            var span_text = '';
            if (check_type == 1) {
                span_text = '拒绝';
            } else if (check_type == 3) {
                span_text = '人工复审';
            }

            let html = '<div>';
            html += '<span style="display:block;margin-top: 6px;margin-left: 21px;">请设置可接受的用户年龄区间:<\/span>';
            html += '<div style="margin-left:43px;margin-top:7px;"><input style="width: 65px;" name="minage" value="' + value_one + '" placeholder="最小年龄">—<input value="' + value_two + '"  style="width: 65px;"  name="maxage"  placeholder="最大年龄"><\/div>';
            html += '<span style="display:block;margin-top: 20px;margin-left: 21px;">超出年龄区间时：<\/span>';
            html += '<div style="margin-left:43px;margin-top:3px;"><span>'+span_text+'</span><\/div>';
            html += '<button style="width:70px;height:28px;margin-left:37px;margin-top:20px;" value="1" name="open">开启<\/button><button name="stop" value="0" style="width:70px;height:28px;margin-left:10px;margin-top:20px;">关闭<\/button>';
            html += '<\/div>';
            let index = layer.open({
                type: 1,
                title: '年龄设置', //不显示标题
                content: html, //注意，如果str是object，那么需要字符拼接。
                area: ['420px', '250px']
            });

            $('input[type=radio]:checked').siblings('span').css('color', '#01AAED');

            if (isopen == 0) {
                $('button[name=stop]').addClass('bgc');
            } else if (isopen == 1) {
                $('button[name=open]').addClass('bgc');
            }

            // $('input[type=radio]').click(function () {
            //     $('input[type=radio]').siblings('span').css('color', '#000');
            //     $('input[type=radio]:checked').siblings('span').css('color', '#01AAED');
            // })

            $('button[name=open]').click(function () {
                if($('input[name=minage]').val() <= 0 || $('input[name=maxage]').val() <= 0){
                    layer.msg('年龄不能等于0');
                    return;
                }
                if($('input[name=minage]').val() >= $('input[name=maxage]').val()){
                    layer.msg('年龄不能交换位置');
                    return;
                }
                $.ajax({
                    url: '/admin/risk/save',
                    type: 'post',
                    data: {
                        'risk_id': 3,
                        'value_one': $('input[name=minage]').val(),
                        'value_two': $('input[name=maxage]').val(),
                        'check_type': check_type,
                        'is_open': 1
                    },
                    success: function (res) {
                        if (res.rspCode == 0) {
                            let minage = $('input[name=minage]').val();
                            let maxage = $('input[name=maxage]').val();
                            let middle = "<年龄<";
                            let innerHtml = "<span>" + minage + "<\/span>" + middle + "<span>" + maxage + "<\/span>";
                            let parent = $(that).parent().parent()[0];
                            parent.children[2].innerHTML = innerHtml;
                            // if ($('input[type=radio]:checked').val() == 1) {
                            //     parent.children[3].innerHTML = '<span data-check_type="1">拒绝<\/span>';
                            // } else {
                            //     parent.children[3].innerHTML = '<span data-check_type="2">通过<\/span>';
                            // }
                            parent.children[4].innerHTML = '<span data-is_open="1">开启<\/span>';
                            layer.close(index);
                        } else {
                            layer.msg(res.message);
                        }
                    }
                });
            });
            $('button[name=stop]').click(function () {
                if($('input[name=minage]').val() <= 0 || $('input[name=maxage]').val() <= 0){
                    layer.msg('年龄不能等于0');
                    return;
                }
                if($('input[name=minage]').val() >= $('input[name=maxage]').val()){
                    layer.msg('年龄不能交换位置');
                    return;
                }
                $.ajax({
                    url: '/admin/risk/save',
                    type: 'post',
                    data: {
                        'risk_id': 3,
                        'value_one': $('input[name=minage]').val(),
                        'value_two': $('input[name=maxage]').val(),
                        'check_type': check_type,
                        'is_open': 0
                    },
                    success: function (res) {
                        if (res.rspCode == 0) {
                            let minage = $('input[name=minage]').val();
                            let maxage = $('input[name=maxage]').val();
                            let middle = "<年龄<";
                            let innerHtml = "<span>" + minage + "<\/span>" + middle + "<span>" + maxage + "<\/span>";

                            let parent = $(that).parent().parent()[0];
                            parent.children[2].innerHTML = innerHtml;
                            // if ($('input[type=radio]:checked').val() == 1) {
                            //     parent.children[3].innerHTML = '<span data-check_type="1">拒绝<\/span>';
                            // } else {
                            //     parent.children[3].innerHTML = '<span data-check_type="2">通过<\/span>';
                            // }
                            parent.children[4].innerHTML = '<span data-is_open="0">关闭<\/span>';
                            layer.close(index);
                        } else {
                            layer.msg(res.message);
                        }
                    }
                });
            });
        })

        $('.base-btn-4').click(function () {
            let that = this;

            let parent = $(that).parent().parent()[0].children;
            let check_type = parent[3].children[0].attributes[0].value;
            let value_one = parent[2].children[0].innerText;
            let isopen = parent[4].children[0].attributes[0].value;
            let risk_id = 4;

            var span_text = '';
            if (check_type == 1) {
                span_text = '拒绝';
            } else if (check_type == 3) {
                span_text = '人工复审';
            }

            var beijin = '';
            var tianjin = '';
            var shanghai = '';
            var chongqin = '';
            var hebei = '';
            var henan = '';
            var hubei = '';
            var hunan = '';
            var jiangsu = '';
            var jiangxi = '';
            var liaolin = '';
            var jiling = '';
            var heilongjiang = '';
            var shanxi = '';
            var sanxi = '';
            var sandong = '';
            var sichuan = '';
            var qinhai = '';
            var anhui = '';
            var hainan = '';
            var guangdong = '';
            var guizhou = '';
            var zhejiang = '';
            var fujian = '';
            var taiwan = '';
            var ganshu = '';
            var yunnan = '';
            var xizang = '';
            var lingxia = '';
            var guangxi = '';
            var xinjiang = '';
            var neimenggu = '';
            var xianggang = '';
            var aomeng = '';

            if(value_one.indexOf('北京市') != -1) beijin = 'checked';
            if(value_one.indexOf('天津市') != -1) tianjin = 'checked';
            if(value_one.indexOf('上海市') != -1) shanghai = 'checked';
            if(value_one.indexOf('重庆市') != -1) chongqin = 'checked';
            if(value_one.indexOf('河北省') != -1) hebei = 'checked';
            if(value_one.indexOf('河南省') != -1) henan = 'checked';
            if(value_one.indexOf('湖北省') != -1) hubei = 'checked';
            if(value_one.indexOf('湖南省') != -1) hunan = 'checked';
            if(value_one.indexOf('江苏省') != -1) jiangsu = 'checked';
            if(value_one.indexOf('江西省') != -1) jiangxi = 'checked';
            if(value_one.indexOf('辽宁省') != -1) liaolin = 'checked';
            if(value_one.indexOf('吉林省') != -1) jiling = 'checked';
            if(value_one.indexOf('黑龙江') != -1) heilongjiang = 'checked';
            if(value_one.indexOf('陕西省') != -1) shanxi = 'checked';
            if(value_one.indexOf('山西省') != -1) sanxi = 'checked';
            if(value_one.indexOf('山东省') != -1) sandong = 'checked';
            if(value_one.indexOf('四川省') != -1) sichuan = 'checked';
            if(value_one.indexOf('青海省') != -1) qinhai = 'checked';
            if(value_one.indexOf('安徽省') != -1) anhui = 'checked';
            if(value_one.indexOf('海南省') != -1) hainan = 'checked';
            if(value_one.indexOf('广东省') != -1) guangdong = 'checked';
            if(value_one.indexOf('贵州省') != -1) guizhou = 'checked';
            if(value_one.indexOf('浙江省') != -1) zhejiang = 'checked';
            if(value_one.indexOf('福建省') != -1) fujian = 'checked';
            if(value_one.indexOf('台湾省') != -1) taiwan = 'checked';
            if(value_one.indexOf('甘肃省') != -1) ganshu = 'checked';
            if(value_one.indexOf('云南省') != -1) yunnan = 'checked';
            if(value_one.indexOf('西藏') != -1) xizang = 'checked';
            if(value_one.indexOf('宁夏') != -1) lingxia = 'checked';
            if(value_one.indexOf('广西') != -1) guangxi = 'checked';
            if(value_one.indexOf('新疆') != -1) xinjiang = 'checked';
            if(value_one.indexOf('内蒙古') != -1) neimenggu = 'checked';
            if(value_one.indexOf('香港') != -1) xianggang = 'checked';
            if(value_one.indexOf('澳门') != -1) aomeng = 'checked';


            let html = '<div>';
            html += '<span style="display:block;margin-top: 6px;margin-left: 21px;">请设置敏感地区:<\/span>';
            html += '<div style="margin-top:7px;padding-left:40px;">';
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+beijin+' name="" value="北京市">&nbsp;<span>北京市<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+tianjin+' name="" value="天津市">&nbsp;<span>天津市<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+shanghai+' name="" value="上海市">&nbsp;<span>上海市<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+chongqin+' name="" value="重庆市">&nbsp;<span>重庆市<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+hebei+' name="" value="河北省">&nbsp;<span>河北省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+henan+' name="" value="河南省">&nbsp;<span>河南省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+hubei+' name="" value="湖北省">&nbsp;<span>湖北省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+hunan+' name="" value="湖南省">&nbsp;<span>湖南省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+jiangsu+' name="" value="江苏省">&nbsp;<span>江苏省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+jiangxi+' name="" value="江西省">&nbsp;<span>江西省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+liaolin+' name="" value="辽宁省">&nbsp;<span>辽宁省<\/span><\/div>'

            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+jiling+' name="" value="吉林省">&nbsp;<span>吉林省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+heilongjiang+' name="" value="黑龙江">&nbsp;<span>黑龙江<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+shanxi+' name="" value="陕西省">&nbsp;<span>陕西省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+sanxi+' name="" value="山西省">&nbsp;<span>山西省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+sandong+' name="" value="山东省">&nbsp;<span>山东省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+sichuan+' name="" value="四川省">&nbsp;<span>四川省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+qinhai+' name="" value="青海省">&nbsp;<span>青海省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+anhui+' name="" value="安徽省">&nbsp;<span>安徽省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+hainan+' name="" value="海南省">&nbsp;<span>海南省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+guangdong+' name="" value="广东省">&nbsp;<span>广东省<\/span><\/div>'

            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+guizhou+' name="" value="贵州省">&nbsp;<span>贵州省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+zhejiang+' name="" value="浙江省">&nbsp;<span>浙江省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+fujian+' name="" value="福建省">&nbsp;<span>福建省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+taiwan+' name="" value="台湾省">&nbsp;<span>台湾省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+ganshu+' name="" value="甘肃省">&nbsp;<span>甘肃省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+yunnan+' name="" value="云南省">&nbsp;<span>云南省<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+xizang+' name="" value="西藏">&nbsp;<span>西藏<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+lingxia+' name="" value="宁夏">&nbsp;<span>宁夏<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+guangxi+' name="" value="广西">&nbsp;<span>广西<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+xinjiang+' name="" value="新疆">&nbsp;<span>新疆<\/span><\/div>'

            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+neimenggu+' name="" value="内蒙古">&nbsp;<span>内蒙古<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+xianggang+' name="" value="香港">&nbsp;<span>香港<\/span><\/div>'
            html += '<div style="display:inline-block;margin-right:10px;margin-top:6px;"><input type="checkbox" '+aomeng+' name="" value="澳门">&nbsp;<span>澳门<\/span><\/div>'
            html += '<\/div>';
            html += '<span style="display:inline-block;margin-top: 20px;margin-left: 21px;">满足敏感地区时：<\/span>';
            html += '<div style="margin-left:43px;margin-top:3px;"><span>'+span_text+'</span><\/div>';
            html += '<button class="submit" style="width:70px;height:28px;margin-left:37px;margin-top:20px;" value="1" name="open">开启<\/button><button class="submit" name="stop" value="0" style="width:70px;height:28px;margin-left:10px;margin-top:20px;">关闭<\/button>';
            html += '<\/div>';
            let index = layer.open({
                type: 1,
                title: '敏感地区', //不显示标题
                content: html, //注意，如果str是object，那么需要字符拼接。
                area: ['536px', '380px']
            });
            $('input[type=radio]:checked').siblings('span').css('color', '#01AAED');
            $('input[type=checkbox]:checked').siblings('span').css('color', '#01AAED');

            if (isopen == 0) {
                $('button[name=stop]').addClass('bgc');
            } else if (isopen == 1) {
                $('button[name=open]').addClass('bgc');
            }

            // $('input[type=radio]').click(function () {
            //     $('input[type=radio]').siblings('span').css('color', '#000');
            //     $('input[type=radio]:checked').siblings('span').css('color', '#01AAED');
            // })

            $('input[type=checkbox]').click(function(){
                $('input[type=checkbox]').siblings('span').css('color', '#000');
                $('input[type=checkbox]:checked').siblings('span').css('color', '#01AAED');
            })

            $('.submit').click(function () {
                let button = this;
                let areas = [];
                let is_open = $(button).val();
                $('input[type=checkbox]:checked').each(function(index, item){
                    areas.push($(item).val());
                });
                areas = areas.join(',');

                $.ajax({
                    url: '/admin/risk/save',
                    type: 'post',
                    data: {
                        'risk_id': risk_id,
                        'value_one': areas,
                        'check_type': check_type,
                        'is_open': is_open
                    },
                    success: function (res) {
                        if (res.rspCode == 0) {
                            let value_one = areas;
                            let innerHtml = "<span>" + value_one + "<\/span>";
                            parent[2].innerHTML = innerHtml;
                            // if ($('input[type=radio]:checked').val() == 1) {
                            //     parent[3].innerHTML = '<span data-check_type="1">拒绝<\/span>';
                            // } else {
                            //     parent[3].innerHTML = '<span data-check_type="2">通过<\/span>';
                            // }
                            if (is_open == 1) {
                                parent[4].innerHTML = '<span data-is_open="1">开启<\/span>';
                            } else if (is_open == 0) {
                                parent[4].innerHTML = '<span data-is_open="0">关闭<\/span>';
                            }
                            layer.close(index);
                        } else {
                            layer.msg(res.message);
                        }
                    }
                });
            });
        })

        function double(button, title, width, height){
            $(button).click(function () {
                let that = this;
                let parent = $(that).parent().parent()[0].children;
                let check_type = parent[3].children[0].attributes[0].value;
                let value_one = parent[2].children[0].innerText;

                if(typeof parent[2].children[1] == 'undefined'){
                    var value_two = '';
                }else{
                    var value_two = parent[2].children[1].innerText;
                }

                let isopen = parent[4].children[0].attributes[0].value;
                let risk_id = button.split('-')[2];
                let desc = parent[1].innerText.split('{numb}');
                let before = desc[0];
                let behand = desc[1];

                var span_text = '';
                if (check_type == 1) {
                    span_text = '拒绝';
                } else if (check_type == 3) {
                    span_text = '人工复审';
                }

                let html = '<div>';
                html += '<span style="display:block;margin-top: 20px;margin-left: 21px;">' + before + '&nbsp;&nbsp;<input style="width: 65px;" name="value_one" value="' + value_one + '" placeholder="">&nbsp;&nbsp;' + behand + '<input style="width: 65px;" name="value_two" value="' + value_two + '" placeholder=""><\/span>';
                html += '<div style="margin-left:43px;margin-top:3px;"><span>'+span_text+'</span><\/div>';
                html += '<button class="submit" style="width:70px;height:28px;margin-left:37px;margin-top:20px;" value="1" name="open">开启<\/button><button class="submit" name="stop" value="0" style="width:70px;height:28px;margin-left:10px;margin-top:20px;">关闭<\/button>';
                html += '<\/div>';
                let index = layer.open({
                    type: 1,
                    title: title, //不显示标题
                    content: html, //注意，如果str是object，那么需要字符拼接。
                    area: [width, height]
                });
                $('input[type=radio]:checked').siblings('span').css('color', '#01AAED');

                if (isopen == 0) {
                    $('button[name=stop]').addClass('bgc');
                } else if (isopen == 1) {
                    $('button[name=open]').addClass('bgc');
                }

                // $('input[type=radio]').click(function () {
                //     $('input[type=radio]').siblings('span').css('color', '#000');
                //     $('input[type=radio]:checked').siblings('span').css('color', '#01AAED');
                // })

                $('.submit').click(function () {
                    let button = this;
                    let is_open = $(button).val();
                    $.ajax({
                        url: '/admin/risk/save',
                        type: 'post',
                        data: {
                            'risk_id': risk_id,
                            'value_one': $('input[name=value_one]').val(),
                            'value_two': $('input[name=value_two]').val(),
                            'check_type': check_type,
                            'is_open': is_open
                        },
                        success: function (res) {
                            if (res.rspCode == 0) {
                                let middle = "<"+title+"<";
                                let value_one = $('input[name=value_one]').val();
                                let value_tow = $('input[name=value_one]').val();

                                let innerHtml = "<span>" + value_one + "<\/span>" + middle + "<span>" + value_tow + "<\/span>";
                                parent[2].innerHTML = innerHtml;
                                // if ($('input[type=radio]:checked').val() == 1) {
                                //     parent[3].innerHTML = '<span data-check_type="1">拒绝<\/span>';
                                // } else {
                                //     parent[3].innerHTML = '<span data-check_type="2">通过<\/span>';
                                // }
                                if (is_open == 1) {
                                    parent[4].innerHTML = '<span data-is_open="1">开启<\/span>';
                                } else if (is_open == 0) {
                                    parent[4].innerHTML = '<span data-is_open="0">关闭<\/span>';
                                }
                                layer.msg(res.message);
                                layer.close(index);
                            } else {
                                layer.msg(res.message);
                            }
                        }
                    });
                });
            })
        }

        function small(button, title, width, height) {
            $(button).click(function () {
                let that = this;

                let parent = $(that).parent().parent()[0].children;
                let check_type = parent[3].children[0].attributes[0].value;
                let isopen = parent[4].children[0].attributes[0].value;
                let desc = parent[1].innerText;
                let risk_id = button.split('-')[2];

                var span_text = '';
                if (check_type == 1) {
                    span_text = '拒绝';
                } else if (check_type == 3) {
                    span_text = '人工复审';
                }

                let html = '<div>';
                html += '<span style="display:block;margin-top: 20px;margin-left: 21px;">' + desc + '<\/span>';
                html += '<div style="margin-left:43px;margin-top:3px;"><span>'+span_text+'</span><\/div>';
                html += '<button class="submit" style="width:70px;height:28px;margin-left:37px;margin-top:20px;" value="1" name="open">开启<\/button><button class="submit" name="stop" value="0" style="width:70px;height:28px;margin-left:10px;margin-top:20px;">关闭<\/button>';
                html += '<\/div>';
                let index = layer.open({
                    type: 1,
                    title: title, //不显示标题
                    content: html, //注意，如果str是object，那么需要字符拼接。
                    area: [width, height]
                });

                $('input[type=radio]:checked').siblings('span').css('color', '#01AAED');

                if (isopen == 0) {
                    $('button[name=stop]').addClass('bgc');
                } else if (isopen == 1) {
                    $('button[name=open]').addClass('bgc');
                }

                // $('input[type=radio]').click(function () {
                //     $('input[type=radio]').siblings('span').css('color', '#000');
                //     $('input[type=radio]:checked').siblings('span').css('color', '#01AAED');
                // })

                $('.submit').click(function () {
                    let button = this;
                    let is_open = $(button).val();
                    $.ajax({
                        url: '/admin/risk/save',
                        type: 'post',
                        data: {
                            'risk_id': risk_id,
                            'check_type': check_type,
                            'is_open': is_open
                        },
                        success: function (res) {
                            if (res.rspCode == 0) {
                                // if ($('input[type=radio]:checked').val() == 1) {
                                //     parent[3].innerHTML = '<span data-check_type="1">拒绝<\/span>';
                                // } else {
                                //     parent[3].innerHTML = '<span data-check_type="2">通过<\/span>';
                                // }
                                if (is_open == 1) {
                                    parent[4].innerHTML = '<span data-is_open="1">开启<\/span>';
                                } else if (is_open == 0) {
                                    parent[4].innerHTML = '<span data-is_open="0">关闭<\/span>';
                                }
                                layer.msg(res.message);
                                layer.close(index);
                            } else {
                                layer.msg(res.message);
                            }
                        }
                    });
                });
            })
        };

        function biger(button, title, width, height) {
            $(button).click(function () {
                let that = this;
                let parent = $(that).parent().parent()[0].children;
                let check_type = parent[3].children[0].attributes[0].value;
                let value_one = parent[2].children[0].innerText;
                let isopen = parent[4].children[0].attributes[0].value;
                let risk_id = button.split('-')[2];
                let desc = parent[1].innerText.split('{numb}');
                let before = desc[0];
                let behand = desc[1];

                var span_text = '';
                if (check_type == 1) {
                    span_text = '拒绝';
                } else if (check_type == 3) {
                    span_text = '人工复审';
                }

                let html = '<div>';
                html += '<span style="display:block;margin-top: 20px;margin-left: 21px;">' + before + '&nbsp;&nbsp;<input style="width: 65px;" name="value_one" value="' + value_one + '" placeholder="">&nbsp;&nbsp;' + behand + '<\/span>';
                html += '<div style="margin-left:43px;margin-top:3px;"><span>'+span_text+'</span><\/div>';
                html += '<button class="submit" style="width:70px;height:28px;margin-left:37px;margin-top:20px;" value="1" name="open">开启<\/button><button class="submit" name="stop" value="0" style="width:70px;height:28px;margin-left:10px;margin-top:20px;">关闭<\/button>';
                html += '<\/div>';
                let index = layer.open({
                    type: 1,
                    title: title, //不显示标题
                    content: html, //注意，如果str是object，那么需要字符拼接。
                    area: [width, height]
                });
                $('input[type=radio]:checked').siblings('span').css('color', '#01AAED');

                if (isopen == 0) {
                    $('button[name=stop]').addClass('bgc');
                } else if (isopen == 1) {
                    $('button[name=open]').addClass('bgc');
                }

                // $('input[type=radio]').click(function () {
                //     $('input[type=radio]').siblings('span').css('color', '#000');
                //     $('input[type=radio]:checked').siblings('span').css('color', '#01AAED');
                // })

                $('.submit').click(function () {
                    let button = this;
                    let is_open = $(button).val();
                    $.ajax({
                        url: '/admin/risk/save',
                        type: 'post',
                        data: {
                            'risk_id': risk_id,
                            'value_one': $('input[name=value_one]').val(),
                            'check_type': check_type,
                            'is_open': is_open
                        },
                        success: function (res) {
                            if (res.rspCode == 0) {
                                let value_one = $('input[name=value_one]').val();
                                let innerHtml = "<span>" + value_one + "<\/span>";
                                parent[2].innerHTML = innerHtml;
                                // if ($('input[type=radio]:checked').val() == 1) {
                                //     parent[3].innerHTML = '<span data-check_type="1">拒绝<\/span>';
                                // } else {
                                //     parent[3].innerHTML = '<span data-check_type="2">通过<\/span>';
                                // }
                                if (is_open == 1) {
                                    parent[4].innerHTML = '<span data-is_open="1">开启<\/span>';
                                } else if (is_open == 0) {
                                    parent[4].innerHTML = '<span data-is_open="0">关闭<\/span>';
                                }
                                layer.msg(res.message);
                                layer.close(index);
                            } else {
                                layer.msg(res.message);
                            }
                        }
                    });
                });
            })
        };
        double('.base-btn-21', '网贷有逾期', '420px', '220px');
        double('.base-btn-32', '近3个月静默天数', '420px', '220px');

        //基础信息
        small('.base-btn-1', '风控初审', '420px', '220px');
        small('.base-btn-2', '风控初审', '420px', '220px');
        small('.base-btn-5', '风控初审', '420px', '220px');
        small('.base-btn-6', '风控初审', '420px', '220px');
        //运营商
        biger('.base-btn-7', '风控初审', '420px', '220px');
        small('.base-btn-8', '风控初审', '420px', '220px');
        small('.base-btn-9', '风控初审', '420px', '220px');
        small('.base-btn-10', '风控初审', '420px', '220px');
        small('.base-btn-11', '风控初审', '420px', '220px');
        small('.base-btn-12', '风控初审', '420px', '220px');
        small('.base-btn-13', '风控初审', '420px', '220px');
        small('.base-btn-14', '风控初审', '420px', '220px');
        biger('.base-btn-15', '风控初审', '420px', '220px');
        small('.base-btn-16', '风控初审', '420px', '220px');
        small('.base-btn-17', '风控初审', '420px', '220px');
        small('.base-btn-18', '风控初审', '420px', '220px');
        small('.base-btn-19', '风控初审', '420px', '220px');
        small('.base-btn-20', '风控初审', '420px', '220px');
        // biger('.base-btn-21', '风控初审', '420px', '220px');
        biger('.base-btn-22', '风控初审', '420px', '220px');
        biger('.base-btn-23', '风控初审', '420px', '220px');
        biger('.base-btn-24', '风控初审', '420px', '220px');
        biger('.base-btn-25', '风控初审', '420px', '220px');
        biger('.base-btn-26', '风控初审', '420px', '220px');
        biger('.base-btn-27', '风控初审', '420px', '220px');
        //疑似欺诈
        biger('.base-btn-28', '风控初审', '420px', '220px');
        biger('.base-btn-29', '风控初审', '420px', '220px');
        biger('.base-btn-30', '风控初审', '420px', '220px');
        small('.base-btn-31', '风控初审', '420px', '220px');
        // biger('.base-btn-32', '风控初审', '420px', '220px');
        small('.base-btn-33', '风控初审', '420px', '220px');
        small('.base-btn-34', '风控初审', '420px', '220px');
        //借款行为
        biger('.base-btn-36', '风控初审', '420px', '220px');
        biger('.base-btn-37', '风控初审', '420px', '220px');
        biger('.base-btn-38', '风控初审', '420px', '220px');
        biger('.base-btn-39', '风控初审', '420px', '220px');
        biger('.base-btn-40', '风控初审', '420px', '220px');


    })
</script>
<script>
</script>
</html>